package com.echo.fm.content.news;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.echo.fm.content.news.model.News;
import com.echo.fm.content.news.model.NewsDto;
import com.echo.util.ErrorException;

@Service("newsService")
public class DefaultNewsServiceImpl implements INewsService {

	@Autowired
	@Qualifier("newsPersistence")
	INewsPersistence newsPersistence;

	public void setNewsPersistence(INewsPersistence newsPersistence) {
		this.newsPersistence = newsPersistence;
	}

	public void addNews(News news) throws ErrorException {
		newsPersistence.addNews(news);
	}

	public void deleteNews(News news) throws ErrorException {
		newsPersistence.deleteNews(news);
	}

	public News searchNewsById(String id) throws ErrorException {
		return newsPersistence.searchNewsById(id);
	}

	public void updateNewsById(News news) throws ErrorException {
		newsPersistence.updateNewsById(news);
	}

	public List<NewsDto> listSearchNews(String title, Long startTimeL, Long endTimeL, Integer status, Integer newsType,
			Integer max, Integer fristNumber) throws ErrorException {
		return newsPersistence.listSearchNews(title, startTimeL, endTimeL, status, newsType, max, fristNumber);
	}
}
